#import "Controller.h"

//I don't like dot notation, SO I DIDN'T USE IT
@implementation Controller
- (IBAction)decrease {
    [poly setNumberOfSides:[poly numberOfSides] - 1];
	[self update];
}

- (IBAction)increase {
    [poly setNumberOfSides:[poly numberOfSides] + 1];
	[self update];

}

- (void)update
{
	//Updates View
	[numberOfSidesLabel setText:[NSString stringWithFormat:@"%@\n%i\n%f",[poly name], [poly numberOfSides], [poly angleInDegrees]]];
	
	switch ([poly numberOfSides]) {
		case 3:
			[decreaseButton setEnabled:NO];
			break;
		case 12:
			[increaseButton setEnabled:NO];
			break;
		default:
			[increaseButton setEnabled:YES];
			[decreaseButton setEnabled:YES];
			break;
	}
}

- (void) awakeFromNib
{
	[poly initWithSides:11 minSides:3 maxSides:12];
	NSLog(@"%@ has been instantiated", [poly name]);
	[self update];
}
@end
